cmake_minimum_required(VERSION 3.28)

project(NetUtils LANGUAGES C)

if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
  message(
    FATAL_ERROR
      "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there."
  )
endif()

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

find_package(cJSON CONFIG REQUIRED)
find_package(iperf CONFIG REQUIRED)

add_library(net_utils STATIC src/net_utils.c)
target_include_directories(net_utils PUBLIC include/)
target_link_libraries(net_utils PUBLIC iperf cjson m)

add_library(net_utils_shared SHARED src/net_utils.c)
target_include_directories(net_utils_shared PUBLIC include/)
target_link_libraries(net_utils_shared PUBLIC iperf cjson m)

add_executable(test_main src/test.c)
target_link_libraries(test_main PUBLIC net_utils m)
add_test(NAME test_main COMMAND test_main)